import allure
from page_object.page_a3mall_login import PageLogin
from page_element.el_A3mall import *
import logging



class EditLogin(PageLogin):
    """首页搜索商品后退出登录"""

    def page_search_exit_login(self, info, casename, expected):
        # 前置条件：已登录
        self.page_login('15985645484', '123456', '输入正确的用户名密码登录成功', '小高4')
        with allure.step(f"输入框输入搜索商品信息"):
            self.send_keys(home_pe.home_search_input, info)
        with allure.step(f"点击搜索按钮"):
            self.click(home_pe.home_search_input_btn)
        with allure.step(f"点击退出"):
            self.click(home_pe.home_exit_btn)
        with allure.step("验证退出成功"):

            # 断言：关键元素可见
            assert self.is_element_visible(login_pe.login_window)

            dy = self.text(login_pe.login_window)
            logging.info(f"预期结果：{expected}，实际结果: {dy}")
            assert expected == dy, \
                f"断言失败(验证失败): 期望等于'{expected}'，实际得到'{dy}'"
            logging.info(f"验证成功,{casename}")
    




